<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$option=$_GET['option'];
$wherep=$_GET['wherep'];
$orderby=getnums($_GET['orderby'],1);
$quser=trim($_GET['quser']);

$tmp_arr['twhereoption'] .= '<a class="thabtn" href="'.getqueurl('wherep',0).'">全部</a><a class="thabtn" href="'.getqueurl('wherep',1).'">本金</a><a class="thabtn" href="'.getqueurl('wherep',2).'">历史本金</a><a class="thabtn" href="'.getqueurl('wherep',3).'">冻结领导奖</a><a class="thabtn" href="'.getqueurl('wherep',6).'">团队收益</a>';
//<a class="thabtn" href="'.getqueurl('wherep',7).'">晋级奖</a><a class="thabtn" href="'.getqueurl('option',8).'">开通会员</a><a class="thabtn" href="'.getqueurl('option',6).'">转商品积分</a><a class="thabtn" href="'.getqueurl('option',2).'">排单</a><a class="thabtn" href="'.getqueurl('wherep',4).'">激活币</a><a class="thabtn" href="'.getqueurl('wherep',5).'">排单币</a>
$tmp_arr['toption'].='<a class="thabtn" href="'.getqueurl('option',0).'">全部</a><a class="thabtn" href="'.getqueurl('option',7).'">注册赠送产出币</a>';

$tmp_arr['torderby']='<a href="'.getqueurl('orderby',geteqval(array($orderby,1,'2','1'))).'" class="'.((strstr($orderby,'1')||strstr($orderby,'2'))?"tpaixusel":"tpaixu").'">'.geteqval(array($orderby,1,'时间↑','时间↓')).'</a>';

if(is_array($GLOBALARR['jjname'])){
foreach ($GLOBALARR['jjname'] as $k => $v) {
	$tmp_arr['tcolor'].='<a href="javascript:;" class="theacolor levelcolor'.$k.'">'.$v.'</a>';
}
}

$condition=' where 1=1 ';

if($quser){
	if(strstr($quser,'-')){
		$qdate=explode('-',$quser);
		if($qdate[0]) $condition.=" and from_unixtime(help_record_time,'%Y')=".$qdate[0]."";
		if($qdate[1]) $condition.=" and from_unixtime(help_record_time,'%m')=".$qdate[1]."";
		if($qdate[2]) $condition.=" and from_unixtime(help_record_time,'%d')=".$qdate[2]."";
	}else{
		$condition.=" and uname like '%".$quser."%'";
	}
}
if(!empty($option)){
	if($option==1){
		//申请充值
		$condition.=" and get_envelope_type = 2";
	}elseif($option==2){
		//排单
		$condition.=" and get_envelope_type in (6,23)";
	}elseif($option==3){
		//获得帮助
		$condition.=" and get_envelope_type in (3,10,11)";
	}elseif($option==4){
		//取消排单
		$condition.=" and get_envelope_type = 17";
	}elseif($option==5){
		//指定会员获取收益
		$condition.=" and get_envelope_type in (16,19)";
	}elseif($option==6){
		//转激活币
		$condition.=" and get_envelope_type = 4";
	}elseif($option==7){
		//转排单币
		$condition.=" and get_envelope_type = 59";
	}elseif($option==8){
		//开通会员
		$condition.=" and get_envelope_type = 8";
	}
}

if(!empty($wherep)){
	if($wherep == 1){
		//可提本息
		$condition.=" and operation_type = 0";
	}elseif($wherep == 2){
		//冻结本息
		$condition.=" and operation_type = 1";
	}elseif($wherep == 3){
		//冻结领导奖
		$condition.=" and operation_type = 2";
	}elseif($wherep == 4){
		//激活币
		$condition.=" and operation_type = 3";
	}elseif($wherep == 5){
		//排单币
		$condition.=" and operation_type = 8";
	}elseif($wherep == 6){
		//可提领导奖
		$condition.=" and operation_type = 9";
	}elseif($wherep == 7){
		//可提领导奖
		$condition.=" and operation_type = 13";
	}
}

$condition .= ' and IFNULL(plus_amount,0) + IFNULL(minus_amount,0) > 0';

$order='';
if($orderby==1) $order=' order by help_record_time asc';
if($orderby==2) $order=' order by help_record_time desc';


$tmp_arr['tth']='<th>序号</th>
						<th>会员账号</th>
						<th>交易类型</th>
						<th>支入</th>
						<th>支出</th>
						<th>账户余额</th>
						<th>账户类型</th>
						<th>交易时间</th>
						<th>备注</th>';
$psql="select count(0) from ld_help_record $condition";
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=finaldetail&pagecount=$pagecount&orderby=$orderby&option=$option&wherep=$wherep&quser=$quser";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];

$sql="select * from ld_help_record  $condition $order limit $offset,$pagecount";
$db->query($sql);
$ii=0;
foreach ($db->rs as $k => $v) {
	$ii++;
	$serialid=($pagearr[2]-1)*$pagecount+$ii;
	if($v['get_envelope_type'] == 2){
		$envelope_type = '申请充值';
	}elseif($v['get_envelope_type'] == 3){
		$envelope_type = '提出领导奖';
	}elseif($v['get_envelope_type'] == 4){
		$envelope_type = '商品积分转账';
	}elseif($v['get_envelope_type'] == 5){
		$envelope_type = '消费劵转账';
	}elseif($v['get_envelope_type'] == 6){
		$envelope_type = '排单扣排单币';
	}elseif($v['get_envelope_type'] == 7){
		$envelope_type = '任务通过加排单币';
	}elseif($v['get_envelope_type'] == 8){
		$envelope_type = '减本金';
	}elseif($v['get_envelope_type'] == 9|| $v['get_envelope_type']==111 ||$v['get_envelope_type']==91){
		$envelope_type = '返还冻结锁仓量';
	}elseif($v['get_envelope_type'] == 10){
		$envelope_type = '提出本息余额';
	}elseif($v['get_envelope_type'] == 11){
		$envelope_type = '排单完成返本金';
	}elseif($v['get_envelope_type'] == 12){
		$envelope_type = '转换商品积分';
	}elseif($v['get_envelope_type'] == 16){
		$envelope_type = '管理员转本息收益';
	}elseif($v['get_envelope_type'] == 17){
		$envelope_type = '取消排单';
	}elseif($v['get_envelope_type'] == 19){
		$envelope_type = '发领导奖';
	}elseif($v['get_envelope_type'] == 23){
		$envelope_type = '排单本金';
	}elseif($v['get_envelope_type'] == 24){
		$envelope_type = '排单扣本金';
	}
	elseif($v['get_envelope_type'] == 31){
		$envelope_type = '加利息';
	}elseif($v['get_envelope_type'] == 32){
		$envelope_type = '减利息';
	}elseif($v['get_envelope_type'] == 33){
		$envelope_type = '加动态奖';
	}elseif($v['get_envelope_type'] == 34){
		$envelope_type = '减动态奖';
	}elseif($v['get_envelope_type'] == 35){
		$envelope_type = '加积分';
	}elseif($v['get_envelope_type'] == 36){
		$envelope_type = '减分';
	}elseif($v['get_envelope_type'] == 37){
		$envelope_type = '晋级奖';
	}elseif($v['get_envelope_type'] == 38){
		$envelope_type = '扣晋级奖';
	}elseif($v['get_envelope_type'] == 40){
		$envelope_type = '扣除商品积分';
	}elseif($v['get_envelope_type'] == 41){
		$envelope_type = '审核未通过返现';
	}elseif($v['get_envelope_type'] == 42){
		$envelope_type = '审核未通过返现';
	}elseif($v['get_envelope_type'] == 43){
		$envelope_type = '审核未通过返现';
	}elseif($v['get_envelope_type'] == 44){
		$envelope_type = '审核未通过返现';
	}elseif($v['get_envelope_type'] == 51){
		$envelope_type = '美业币转入现金';
	}elseif($v['get_envelope_type'] == 65){
		$envelope_type = '冻结转入积分';
	}elseif($v['get_envelope_type'] == 66){
		$envelope_type = '冻结转入动态';
	}elseif($v['get_envelope_type'] == 60){
		$envelope_type = '转入积分';
	}elseif($v['get_envelope_type'] == 61){
		$envelope_type = '转入动态';
	}elseif($v['get_envelope_type'] == 62){
		$envelope_type = '转入冻结积分';
	}elseif($v['get_envelope_type'] == 63){
		$envelope_type = '冻结动态';
	}elseif($v['get_envelope_type'] == 90){
		$envelope_type = '减团队收益';
	}elseif($v['get_envelope_type'] == 110){
		$envelope_type = '减静态收益';
	}elseif($v['get_envelope_type'] == 113){
		$envelope_type = '每天加静态收益';
	}
	elseif($v['get_envelope_type'] == 170|| $v['get_envelope_type']==180||$v['get_envelope_type']==230){
		$envelope_type = '减冻结锁仓量';
	}elseif($v['get_envelope_type'] == 171|| $v['get_envelope_type']==181||$v['get_envelope_type']==231){
		$envelope_type = '增加结锁仓量';
	}
	elseif($v['get_envelope_type'] == 200){
		$envelope_type = '减共享积分';
	}elseif($v['get_envelope_type'] == 201){
		$envelope_type = '加共享积分';
	}elseif($v['get_envelope_type'] == 1561){
		$envelope_type = '比特币转入';
	}elseif($v['get_envelope_type'] == 1571){
		$envelope_type = '莱特币转入';
	}elseif($v['get_envelope_type'] == 59){
	    $envelope_type = '赠送产生币';
	}
	
	if($v['operation_type'] == 0){
		$optype = '本金';
	}elseif($v['operation_type'] == 1){
		$optype = '历史本金';
	}elseif($v['operation_type'] == 2){
		$optype = '冻结领导奖';
	}elseif($v['operation_type'] == 3){
		$optype = '商品积分';
	}elseif($v['operation_type'] == 8){
		$optype = '消费劵';
	}elseif($v['operation_type'] == 9){
		$optype = '团队收益';
	}elseif($v['operation_type'] == 11){
		$optype = '静态收益';
	}elseif($v['operation_type'] == 12){
		$optype = '积分';
	}elseif($v['operation_type'] == 13){
		$optype = '晋级奖';
	}elseif($v['operation_type'] == 17){
		$optype = '冻结静态收益';
	}elseif($v['operation_type'] == 18){
		$optype = '冻结团队收益';
	}elseif($v['operation_type'] == 23){
		$optype = '冻结本金';
	}elseif($v['operation_type'] == 156){
		$optype = '比特币';
	}elseif($v['operation_type'] == 157){
		$optype = '莱特币';
	}
	$rm=$member->getuserinfo($v['uname'],1);
	$tmp_arr['ttr'].='<tr class="levelcolor'.$rm['user_level'].'">
						<td><span  title="'.$rm["id"].'">'.$serialid.'</span></td>
						<td>'.$v['uname'].'</td>
						<td>'.$envelope_type.'</td>
						<td>'.$v['plus_amount'].'</td>
						<td>'.$v['minus_amount'].'</td>
						<td>'.$v['usable_amount'].'</td>
							<td>'.$optype.'</td>
							<td>'.date("Y-m-d H:i:s",$v['help_record_time']).'</td>
							<td>'.$v['description'].'</td></tr>';
}


$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'finaldetail');
$tmp_arr['tpage']=$pagearr[0];

admin_two($tmp_arr);
if($_GET['option'] == 1 && $_GET['wherep'] == 4){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type = 2 and operation_type = 3",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>申请充值激活币合计：+".$heji['am']."</span></div>";
}
if($_GET['option'] == 1 && $_GET['wherep'] == 5){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type = 2 and operation_type = 8",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>申请充值排单币合计：+".$heji['am']."</span></div>";
}
if($_GET['option'] == 2 && $_GET['wherep'] == 2){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type in (6,23) and operation_type=1",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>排单增加冻结本息合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 2 && $_GET['wherep'] == 5){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type in (6,23) and operation_type=8",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>排单扣排单币合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 3 && $_GET['wherep'] == 1){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type in (3,10,11) and operation_type=0",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>获得帮助减可提本息合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 3 && $_GET['wherep'] == 6){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type in (3,10,11) and operation_type=9",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>获得帮助减可提领导奖合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 4 && $_GET['wherep'] == 2){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type = 17 and operation_type=1",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>取消排单减冻结本息合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 4 && $_GET['wherep'] == 3){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type = 17 and operation_type=2",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>取消排单减冻结领导奖合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 4 && $_GET['wherep'] == 5){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type = 17 and operation_type=8",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>取消排单加排单币合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 5 && $_GET['wherep'] == 1){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type in (16,19) and operation_type=0",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>指定会员获取收益加可提本息合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 5 && $_GET['wherep'] == 2){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type in (16,19) and operation_type=1",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>指定会员获取收益减冻结本息合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 5 && $_GET['wherep'] == 6){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type in (16,19) and operation_type=9",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>指定会员获取收益加可提领导奖合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 5 && $_GET['wherep'] == 3){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type in (16,19) and operation_type=2",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>指定会员获取收益减冻结领导奖合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 6 && $_GET['wherep'] == 4){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type = 4 and operation_type=3",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>转商品积分增加合计：+".$heji['am']."</span></div>";
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type = 4 and operation_type=3",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>转商品积分减少合计：+".$heji['am']."</span></div>";
}
if($_GET['option'] == 7 && $_GET['wherep'] == 5){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type = 5 and operation_type=8",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>转排单币增加合计：".$heji['am']."</span></div>";
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type = 5 and operation_type=8",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>转排单币减少合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 8){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type = 8",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>开通会员扣激活币合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 9 && $_GET['wherep'] == 3){
	$db->query("select SUM(minus_amount) as am from ld_help_record where get_envelope_type = 19 and operation_type=2",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>确认收款减冻结领导奖合计：".$heji['am']."</span></div>";
}
if($_GET['option'] == 9 && $_GET['wherep'] == 6){
	$db->query("select SUM(plus_amount) as am from ld_help_record where get_envelope_type = 19 and operation_type=9",2);
	$heji = $db->rs;
	echo "<div style='font-size:14px;'><span>确认收款加可提领导奖合计：".$heji['am']."</span></div>";
}
?>